package com.hualude.roadsign.controller;

import com.hualude.roadsign.dto.DTRequestDto;
import com.hualude.roadsign.dto.DTResponseDto;
import com.hualude.roadsign.dto.JsonMsgDto;
import com.hualude.roadsign.service.GuardrailFaultHandleService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by ding on 2017/8/15.
 */
@Controller
@RequestMapping("/rds_guardrailFaultHandle")
public class GuardrailFaultHandleController {
    @Resource
    private GuardrailFaultHandleService guardrailFaultHandleService;


    @RequestMapping(value = "/getGuardrailFaultHandle4DT")
    @ResponseBody
    public DTResponseDto getGuardrailFaultHandle4DT(DTRequestDto dtRequestDto, String actorIds , Integer orgId, Integer maintenanceStatus) {
        DTResponseDto dtResponseDto = new DTResponseDto();
        try {
            dtResponseDto = guardrailFaultHandleService.getGuardrailFaultHandle4DT(dtRequestDto,actorIds, orgId,maintenanceStatus);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dtResponseDto;
    }

    @RequestMapping("/addGuardrailMaintenanceContent")
    @ResponseBody
    public JsonMsgDto addGuardrailMaintenanceContent(Integer guardrailFaultId, String guardrailMaintenanceContent) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(guardrailFaultHandleService.addGuardrailMaintenanceContent(guardrailFaultId, guardrailMaintenanceContent));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);
        }
        return jsonMsgDto;
    }

    @RequestMapping("/finishGuardrailMaintenance")
    @ResponseBody
    public JsonMsgDto finishGuardrailMaintenance(String guardrailMaintenancePhoto,Integer guardrailMaintainerId,String guardrailMaintenanceTime,String guardrailMaintenanceExplain,Integer guardrailFaultId) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(guardrailFaultHandleService.finishGuardrailMaintenance(guardrailMaintenancePhoto,guardrailMaintainerId,guardrailMaintenanceTime,guardrailMaintenanceExplain,guardrailFaultId));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);
        }
        return jsonMsgDto;
    }

    @RequestMapping("/getGuardrailFaultHandleList4App")
    @ResponseBody
    public JsonMsgDto getGuardrailFaultHandleList4App(Integer orgId, Integer maintenanceStatus, String actorIds, Integer count, Integer size) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(guardrailFaultHandleService.getGuardrailFaultHandleList4App(orgId, maintenanceStatus, actorIds, count, size));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);

        }
        return jsonMsgDto;
    }

    @RequestMapping("/getGuardrailReceiptInfo4App")
    @ResponseBody
    public JsonMsgDto getGuardrailReceiptInfo4App(Integer faultId) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(guardrailFaultHandleService.getGuardrailReceiptInfo4App(faultId));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);
        }
        return jsonMsgDto;
    }
}
